// 主题映射
@mixin themify($themes: $themes) {
  @each $theme-name, $map in $themes {
    // & 表示父级元素
    // !global 表示覆盖原来的
    .theme-#{"" + $theme-name} & {
      $theme-map: () !global;
      // 循环合并键值对
      @each $key, $value in $map {
        $theme-map: map-merge(
          $theme-map,
          (
            $key: $value
          )
        ) !global;
      }
      // 表示包含 下面函数 themed()
      @content;

      $theme-map: null !global;
    }
  }
}
@function themed($key) {
  @return map-get($theme-map, $key);
}

/* 使用
@include themify() {
  background-color: themed('header-bg');
}
*/

$themes: (
  blue: (
    // header
    header-bg: #187fea,
    nav-bg: #fff,
    nav-active: #1467c0,
    nav-color: #555,
    nav-hover-color: #fff,
    title: #1890ff
  ),
  dark: (
    // header
    header-bg: #364860,
    nav-bg: #2a3950,
    nav-active: #1890ff,
    nav-color: #fff,
    nav-hover-color: #fff,
    title: #1890ff
  ),
  green: (
    // header
    header-bg: #0099a6,
    nav-bg: #fff,
    nav-active: #00808b,
    nav-color: #555,
    nav-hover-color: #fff,
    title: #0099a6
  ),
  red: (
    // header
    header-bg: #d92530,
    nav-bg: #fff,
    nav-active: #aa1e27,
    nav-color: #555,
    nav-hover-color: #fff,
    title: #d92530
  )
);
